<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                template="../template/template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sec="http://www.springframework.org/security/facelets/tags" 
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <ui:define name="corpo">
        <h:form>
            <div class="page-header">
                <h1><small>Configuração - Envio de e-mails</small></h1>
            </div>
            <ol class="breadcrumb">
                <li>Home</li>
                <li>Configurações</li>
                <li class="active">E-mail</li>
            </ol>
            <p:growl life="6000" id="growl"/>
            #{controllerMail.preencherFormulario()}
            <center>
                <h:panelGrid columns="2">
                    <!-- ESPACO -->
                    <h:inputHidden value="#{controllerMail.email.id}"/>
                    <p:outputLabel value="SMTP"/>
                    <p:inputText value="#{controllerMail.email.smtp}" maxlength="60" style="width: 500px"/>

                    <p:outputLabel value="SSL" styleClass="margin-top-text"/>
                    <p:selectBooleanCheckbox style="margin-top: 3px;" value="#{controllerMail.email.ssl}" />

                    <p:outputLabel value="Porta" styleClass="margin-top-text"/>
                    <p:inputMask styleClass="margin-top-input"  mask="999" value="#{controllerMail.email.porta}" style="width: 60px;"/>

                    <p:outputLabel value="Usuário" styleClass="margin-top-text"/>
                    <p:inputText styleClass="margin-top-input" value="#{controllerMail.email.usuario}" maxlength="65" style="width: 500px;"/>

                    <p:outputLabel value="Senha" styleClass="margin-top-text"/>
                    <p:inputText styleClass="margin-top-input" value="#{controllerMail.email.senha}" maxlength="18" style="width: 120px;"/>



                    <p:outputLabel value="E-mail" styleClass="margin-top-text"/>
                    <p:inputText styleClass="margin-top-input" value="#{controllerMail.email.email}" maxlength="65" style="width: 500px">
                        <f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
                    </p:inputText>

                    <p:outputLabel value="Título" styleClass="margin-top-text"/>
                    <p:inputText styleClass="margin-top-input" value="#{controllerMail.email.titulo}" maxlength="60" style="width: 500px"/>
                </h:panelGrid>
                <br/>
                <h:panelGrid columns="1">
                    <p:outputLabel value="Mensagem:"/>
                    <p:editor id="editor" value="#{controllerMail.email.mensagem}" width="600" height="200"/>
                </h:panelGrid>
                <br/>
                <c:if test="#{controllerMail.lista.size()>0}">
                    <p:commandButton actionListener="#{controllerMail.merge()}" value="Salvar" update="@form"/>
                </c:if>
                <c:if test="#{controllerMail.lista.size()==0}">
                    <p:commandButton actionListener="#{controllerMail.salvar()}" value="Salvar" update="@form"/>
                </c:if>
                
            </center>
        </h:form>
    </ui:define>
</ui:composition>